package com.lan.support.response.json;


import com.lan.support.response.ex.Ex;
import com.lan.support.response.ex.ExCode;

public class R {
    private Object result;
    private boolean success = true;
    private String message;

    private Integer code = 200;

    public R() {
    }

    public R(Object result) {
        this.result = result;
    }

    public R(String message, boolean success) {
        this.message = message;
        this.success = success;
    }

    public R(Object result, String message, boolean success) {
        this.result = result;
        this.message = message;
        this.success = success;
    }

    public R(String message, Integer code, boolean success) {
        this.success = success;
        this.message = message;
        this.code = code;
    }

    public static R OK(Object result) {
        R j = new R(result);
        return j;
    }

    public static R OK() {
        R j = new R();
        return j;
    }

    public static R Fail(String message) {
        R j = new R(message, -10000, false);
        return j;
    }

    public static R Fail() {
        R j = new R(null, -10000, false);
        return j;
    }

    public static R Fail(Ex ex) {
        R j = new R(ex.getName(), ex.getCode(), false);
        return j;
    }

    public static R Fail(ExCode ex) {
        R j = new R(ex.getName(), ex.getCode(), false);
        return j;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
